package com.ruoyi.project.channel.businessPauseOrderSetting.controller;

import java.util.Date;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.channel.businessPauseOrderSetting.domain.BusinessPauseOrderSetting;
import com.ruoyi.project.channel.businessPauseOrderSetting.service.IBusinessPauseOrderSettingService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 卡单状态配置信息操作处理
 * 
 * @author CAIN
 * @date 2024-10-18
 */
@Controller
@RequestMapping("/channel/businessPauseOrderSetting")
public class BusinessPauseOrderSettingController extends BaseController
{
    private String prefix = "channel/businessPauseOrderSetting";
	
	@Autowired
	private IBusinessPauseOrderSettingService businessPauseOrderSettingService;
	
	@RequiresPermissions("channel:businessInfo:view")
	@GetMapping()
	public String businessPauseOrderSetting()
	{
	    return prefix + "/businessPauseOrderSetting";
	}

	@RequiresPermissions("channel:businessInfo:view")
	@GetMapping("/list/view/{userId}")
	public String businessPauseOrderSetting(@PathVariable("userId") Long userId, ModelMap mmap)
	{
		mmap.put("userId", userId);
		return prefix + "/businessPauseOrderSetting";
	}

	/**
	 * 查询卡单状态配置列表
	 */
	@RequiresPermissions("channel:businessInfo:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(BusinessPauseOrderSetting businessPauseOrderSetting)
	{
		startPage();
        List<BusinessPauseOrderSetting> list = businessPauseOrderSettingService.selectBusinessPauseOrderSettingList(businessPauseOrderSetting);
		return getDataTable(list);
	}

	/**
	 * 查询卡单状态配置列表
	 */
	@RequiresPermissions("channel:businessInfo:list")
	@PostMapping("/list/{userId}")
	@ResponseBody
	public TableDataInfo listUserId(@PathVariable("userId") Long userId, BusinessPauseOrderSetting businessPauseOrderSetting)
	{
		businessPauseOrderSetting.setUserId(userId);
		startPage();
		List<BusinessPauseOrderSetting> list = businessPauseOrderSettingService.selectBusinessPauseOrderSettingList(businessPauseOrderSetting);
		return getDataTable(list);
	}
	/**
	 * 导出卡单状态配置列表
	 */
	@RequiresPermissions("channel:businessPauseOrderSetting:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BusinessPauseOrderSetting businessPauseOrderSetting)
    {
    	List<BusinessPauseOrderSetting> list = businessPauseOrderSettingService.selectBusinessPauseOrderSettingList(businessPauseOrderSetting);
        ExcelUtil<BusinessPauseOrderSetting> util = new ExcelUtil<BusinessPauseOrderSetting>(BusinessPauseOrderSetting.class);
        return util.exportExcel(list, "businessPauseOrderSetting");
    }
	
	/**
	 * 新增卡单状态配置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}

	/**
	 * 新增卡单状态配置
	 */
	@GetMapping("/add/{userId}")
	public String addView(@PathVariable("userId") Long userId, ModelMap mmap)
	{
		mmap.put("userId", userId);
		return prefix + "/add";
	}
	
	/**
	 * 新增保存卡单状态配置
	 */
	@RequiresPermissions("channel:businessInfo:edit")
	@Log(title = "卡单状态配置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(BusinessPauseOrderSetting businessPauseOrderSetting)
	{		
		return toAjax(businessPauseOrderSettingService.insertBusinessPauseOrderSetting(businessPauseOrderSetting));
	}

	/**
	 * 新增保存卡单状态配置
	 */
	@RequiresPermissions("channel:businessInfo:edit")
	@Log(title = "卡单状态配置", businessType = BusinessType.INSERT)
	@PostMapping("/add/{userId}")
	@ResponseBody
	public AjaxResult addSaveUser(@PathVariable("userId") Long userId, BusinessPauseOrderSetting businessPauseOrderSetting)
	{
		businessPauseOrderSetting.setUserId(userId);
		businessPauseOrderSetting.setPayStatus("未完成");
		businessPauseOrderSetting.setUpdateTime(new Date());
		businessPauseOrderSetting.setCreateTime(new Date());
		return toAjax(businessPauseOrderSettingService.insertBusinessPauseOrderSetting(businessPauseOrderSetting));
	}

	/**
	 * 修改卡单状态配置
	 */
	@GetMapping("/edit/{userId}")
	public String edit(@PathVariable("userId") Long userId, ModelMap mmap)
	{
		BusinessPauseOrderSetting businessPauseOrderSetting = businessPauseOrderSettingService.selectBusinessPauseOrderSettingById(userId);
		mmap.put("businessPauseOrderSetting", businessPauseOrderSetting);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存卡单状态配置
	 */
	@RequiresPermissions("channel:businessInfo:edit")
	@Log(title = "卡单状态配置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(BusinessPauseOrderSetting businessPauseOrderSetting)
	{		
		return toAjax(businessPauseOrderSettingService.updateBusinessPauseOrderSetting(businessPauseOrderSetting));
	}
	
	/**
	 * 删除卡单状态配置
	 */
	@RequiresPermissions("channel:businessInfo:remove")
	@Log(title = "卡单状态配置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(businessPauseOrderSettingService.deleteBusinessPauseOrderSettingByIds(ids));
	}
	
}
